using System;
using System.Collections.Generic;
using System.Text;
using Wilco.SyntaxHighlighting;
using System.Windows.Forms;

namespace CodeSyntaxHighLighter
{
	internal static class HighLighterUtils
	{
		public static void FillInHighLighters(ImgComboBox combo)
		{
			combo.Items.Clear();
			foreach (HighlighterBase hl in Register.Instance.Highlighters)
			{
				string key = hl.Name.ToLower();
				ImageComboItem iitem = new ImageComboItem();
				if (LanguagesList.Images.ContainsKey(key))
					iitem.Image = LanguagesList.Images[key];
				else
					iitem.Image = LanguagesList.Images[0];
				iitem.Text = hl.Name;
				combo.Items.Add(iitem);

			}
		}

		private static ImageList _languageList;
		private static ImageList LanguagesList
		{
			get
			{
				if (_languageList == null)
				{
					_languageList = new ImageList();
					_languageList.ImageStream = Properties.Resources.LanguageImages;
					_languageList.TransparentColor = System.Drawing.Color.Transparent;
					_languageList.Images.SetKeyName(0, "general");
					_languageList.Images.SetKeyName(1, "xml");
					_languageList.Images.SetKeyName(2, "aspx");
					_languageList.Images.SetKeyName(3, "c");
					_languageList.Images.SetKeyName(4, "cobol");
					_languageList.Images.SetKeyName(5, "coldfusion");
					_languageList.Images.SetKeyName(6, "cpp");
					_languageList.Images.SetKeyName(7, "c#");
					_languageList.Images.SetKeyName(8, "css");
					_languageList.Images.SetKeyName(9, "eiffel");
					_languageList.Images.SetKeyName(10, "fortran");
					_languageList.Images.SetKeyName(11, "haskell");
					_languageList.Images.SetKeyName(12, "html");
					_languageList.Images.SetKeyName(13, "java");
					_languageList.Images.SetKeyName(14, "javascript");
					_languageList.Images.SetKeyName(15, "msil");
					_languageList.Images.SetKeyName(16, "pascal");
					_languageList.Images.SetKeyName(17, "perl");
					_languageList.Images.SetKeyName(18, "php");
					_languageList.Images.SetKeyName(19, "python");
					_languageList.Images.SetKeyName(20, "ruby");
					_languageList.Images.SetKeyName(21, "sql");
					_languageList.Images.SetKeyName(22, "visualbasic");
					_languageList.Images.SetKeyName(23, "visualbasicscript");
					_languageList.Images.SetKeyName(24, "jscript");
				}
				return _languageList;
			}
		}
	}
}
